﻿#region

using System;
using System.Net;
using Lunexx.Config;
using Lunexx.Network.Master;
using Lunexx.Network.World;

#endregion

namespace Lunexx
{
    internal class Program
    {
        public static Settings LunexxSettings;

        public static void Main()
        {
            ConsoleWrapper.DisplayBanner();
            MasterListener master = null;
            WorldListener world = null;
            try
            {
                master = new MasterListener(IPAddress.Any, 15550,
                                            new IPEndPoint(new IPAddress(new byte[4] {206, 82, 213, 70}), 15550));
                master.StartListening();
                ConsoleWrapper.MasterWriteLine("Succesfully created new MasterListner", 1);
                ConsoleWrapper.MasterWriteLine("Accepting Connections on :15550", 1);
            }
            catch (Exception e)
            {
                ConsoleWrapper.DebugWrite("Failed to create MasterListener", 1);
                ConsoleWrapper.DebugWrite(e.ToString(), 2);
            }

            try
            {
                world = new WorldListener(IPAddress.Any, 15551,
                                          new IPEndPoint(new IPAddress(new byte[4] {206, 82, 213, 70}), 15551));
                world.StartListening();
                ConsoleWrapper.WorldWriteLine("Succesfully created new MasterListner", 1);
                ConsoleWrapper.WorldWriteLine("Accepting Connections on :15551", 1);
            }
            catch (Exception e)
            {
                ConsoleWrapper.DebugWrite("Failed to create WorldListener", 1);
                ConsoleWrapper.DebugWrite(e.ToString(), 2);
            }

            Console.ReadLine();
            if (master != null) master.Dispose();
            if (world != null) world.Dispose();
        }
    }
}